/*
 ------------------------------------------------------------------------------
 Copyright (C) 1996-2001 Id Software, Inc.

 This file is part of the Quake source code.

 The Quake source code is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or (at your
 option) any later version.

 The Quake source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 more details.

 You should have received a copy of the GNU General Public License along with
 the Quake source code; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 ------------------------------------------------------------------------------
*/


//
// cg_public.h - public header to all other files
//


#ifndef __CG_PUBLIC_H__
#define __CG_PUBLIC_H__


#define CGAME_API_VERSION			1

typedef struct glqCGame_t *	(*GETCGAMEAPI)(struct etClient_t *);

// Functions exported by the game module
struct glqCGame_t {
	int						apiVersion;

	// Parses a game state from the server.
	// Returns an offset to request the remaining data, or -1 if the entire
	// game state has been parsed.
	// This is only used during the connection process, before loading the
	// level.
	int						(*ParseGameState)(msg_t *msg);

	// Parses a snapshot from the server.
	// Returns true if the snapshot was valid and sets the time and
	// deltaCompressed parameters.
	bool					(*ParseSnapshot)(msg_t *msg, int sequence, int *time, bool *deltaCompressed);

	// Executes a string command from the server.
	// The string has been tokenized by the engine and the command system
	// functions can be used to retrieve the command arguments.
	void					(*ServerCommand)();

	// Loads the current level.
	// This will also be called after a client subsystem restart.
	void					(*LoadLevel)();

	// Frees the current level.
	// This will also be called before a client subsystem restart.
	void					(*FreeLevel)();

	// Starts playing a music track for the loaded level
	void					(*PlayBackgroundTrack) ();

	// Runs a game frame
	void					(*RunFrame)(int time, const userCmd_t *userCmd);

	// Redraws the game view
	void					(*Redraw)();

	// Initializes the game
	void					(*Init)(bool demoPlaying, int clientNum, int serverMessageSequence);

	// Shuts down the game
	void					(*Shutdown)();
};

// Functions imported from the engine
struct etClient_t {
	glqCommon_t				glqCommon;
	glqMemory_t				glqMemory;
	glqFileSystem_t			glqFileSystem;
	glqCmdSystem_t			glqCmdSystem;
	glqCVarSystem_t			glqCVarSystem;
	glqMsgSystem_t			glqMsgSystem;
	glqDefManager_t			glqDefManager;
	glqParser_t				glqParser;
	glqSystem_t				glqSystem;
	glqTable_t				glqTable;
	glqCollision_t			glqCollision;
	glqRenderer_t			glqRenderer;
	glqSound_t				glqSound;
	glqGUI_t				glqGUI;

	// Gets the current user command number
	int						(*GetUserCmdNumber)();

	// Gets the given user command
	void					(*GetUserCmd)(int userCmdNumber, userCmd_t *userCmd);

	// Sets the jitter angles (kick angles, shake angles, etc)
	void					(*SetJitterAngles)(float pitch, float yaw);

	// Sets the mouse view sensitivity scale factor
	void					(*SetSensitivityScale)(float sensitivityScale);

	// Processes events and updates the screen and sounds to let the loading
	// GUI refresh
	void					(*UpdateLoading)();
};


#endif	// __CG_PUBLIC_H__